﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using mKoenig.PictureSlide.Properties;

namespace mKoenig.PictureSlide
{
  public class TransitionEnabler
  {
    private static Settings setting = Settings.Default;
    private static Random rand = new Random();

    public static bool isEnabled(int Transition)
    {
      if (Transition > 100) return false;

      DataTable set = setting.DisableTransition;
      if (set == null)
      {
        set = new DataTable("DisableTransition");

        for (int i = 0; i < 100; i++)
        {
          set.Columns.Add(i.ToString());
        }
        setting.DisableTransition = set;
        setting.Save();
      }

      if (set.Rows.Count == 0)
      {
        DataRow row = set.NewRow();
        for (int i = 0; i < 100; i++)
        {
          row[i] = "false";
        }
        set.Rows.Add(row);
      }

      if (set.Rows[0][Transition].ToString() == "true") return false;

      return true;
    }
    public static int NextTransition()
    {
      List<int> list = new List<int>();
      for (int i = 0; i < Render.Count; i++)
      {
        if (isEnabled(i))
        {
          list.Add(i);
        }
      }

      int x = rand.Next(list.Count);
      return list[x];
    }

  }
}
